<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JavaScript简易年历</title>
    <style>
        * { padding: 0; margin: 0; }
        li { list-style: none; }
        body { background: #f6f9fc; font-family: arial; }

        .calendar { width: 210px; margin: 0 auto; padding: 10px 10px 20px 20px; background: #eae9e9; }
        .calendar ul { width: 210px; overflow: hidden; padding-bottom: 10px; }
        .calendar li { float: left; width: 58px; height: 54px; margin: 10px 10px 0 0; border: 1px solid #fff; background: #424242; color: #fff; text-align: center; cursor: pointer; }
        .calendar li h2 { font-size: 20px; padding-top: 5px; }
        .calendar li p { font-size: 14px; }

        .calendar .active { border: 1px solid #424242; background: #fff; color: #e84a7e; }
        .calendar .active p { font-weight: bold; }

        .calendar .text { width: 178px; padding: 0 10px 10px; border: 1px solid #fff; padding-top: 10px; background: #f1f1f1; color: #555; }
        .calendar .text h2 {font-size: 14px; margin-bottom: 10px; }
        .calendar .text p { font-size: 12px; line-height: 18px; }
    </style>

</head>

<body>

<div id="tab" class="calendar">
    <ul id="box">
        <li class="active">
        	<h2>1</h2>
        	<p>JAN</p>
        </li>
        <li>
        	<h2>2</h2>
        	<p>FER</p>
        </li>
        <li>
        	<h2>3</h2>
        	<p>MAR</p>
        </li>
        <li>
        	<h2>4</h2>
        	<p>APR</p>
        </li>
        <li>
        	<h2>5</h2>
        	<p>MAY</p>
        </li>
        <li>
        	<h2>6</h2>
        	<p>JUN</p>
        </li>
        <li>
        	<h2>7</h2>
        	<p>JUL</p>
        </li>
        <li>
        	<h2>8</h2>
        	<p>AUG</p>
        </li>
        <li>
        	<h2>9</h2>
        	<p>SEP</p>
        </li>
        <li>
        	<h2>10</h2>
        	<p>OCT</p>
        </li>
        <li>
        	<h2>11</h2>
        	<p>NOV</p>
        </li>
        <li>
        	<h2>12</h2>
        	<p>DEC</p>
        </li>
    </ul>
    
    <div id="txtshow" class="text" >
        <h2>1月活动</h2>
        <p>快过年了，大家可以商量着去哪玩吧～</p>
    </div>

</div>
<script>
window.onload = function(){
	var ajson = [
    	["1月到啦！","快过年了，大家商量着去哪玩吧～"],
    	["2月到啦！","过年了，出来放鞭炮啊啊吧～"],
    	["3月到啦！","开学啦，该开学啦，报名去～"],
    	["4月到啦！","上班啦，懒猪起床～"],
    	["5月到啦！","该挣钱啦，娃娃买奶粉啊～"],
    	["6月到啦！","走起，去玩吧～"],
    	
    	["7月到啦！","我要结婚，份子钱交来～"],
    	["8月到啦！","生娃啦，逗啊～"],
    	["9月到啦！","嘿嘿，尿你一裤子～"],
    	["10月到啦！","醒醒，给娃端尿～"],
    	["11月到啦！","我带你，去金香鲍吃大餐去～"],
    	["12月到啦！","哈哈哈了，跟我走秀秀秀～"],  	
    ];
	var oLi = (document.getElementById("box")).getElementsByTagName("li");
	var oDiv = document.getElementById("txtshow");
	console.log(oLi);
	console.log(oDiv);
	var oH2 = oDiv.firstElementChild;
	var oP = oDiv.lastElementChild;	
    for (var i = 0;i<oLi.length;i++) {
		oLi[i].index =  i;
		oLi[i].onclick = function(){
			for(var j = 0;j<oLi.length;j++){
				oLi[j].className = "";
			}
			this.className = "active";
			oH2.innerHTML = ajson[this.index][0];
			oP.innerHTML = ajson[this.index][1];			
		}	
	}	

}





</script>
</body>
</html>